package controller;

import model.Aluno;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import dao.AlunoDao;

import service.AlunoServico;
import exception.ConexaoException;

@Controller
@RequestMapping("/aluno")
public class AlunoController {
	private final AlunoServico servico;
	@Autowired
	public AlunoController(AlunoServico servico){
		this.servico = servico;
		System.out.println("aaaaaaaaaaaa Chegou no controller!");
	}
	
	@RequestMapping("/")
	public ModelAndView listar(){
		return servico.listar();
	}
	
	
	
	@RequestMapping("/novo")
	public ModelAndView novo(){
		return servico.novo();
	}
	
	@RequestMapping(value="/persistir", method= RequestMethod.POST)
	public ModelAndView perssistir(Aluno aluno){
		return servico.persistir(aluno);
	}
	
	@RequestMapping("/editar")
	public ModelAndView editar(long id){
		return servico.editar(id);
	}
	
	@RequestMapping("/excluir")
	public ModelAndView excluir(long id){
		return servico.excluir(id);
	}
	
	
	
	
}
